import itertools

import gmpy2

a = ['9', '8', '7', '6', '5', '4', '3', '2', '1']
for i in range(-9, -3, 1):
    for j in itertools.permutations(a[i:]):
        t = int(''.join(j))
        if gmpy2.is_prime(t):
            print(t)
            exit(0)
